#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
bool judge(char str[])
{
	if (strlen(str) < 8 || strlen(str) > 16)return false;
	int check1, check2, check3, check4;
	check1 = check2 = check3 = check4 = 0;
	for (int i = 0; i < strlen(str); i++)
	{
		if (str[i] >= 'A' && str[i] <= 'Z')check1 = 1;
		else if (str[i] >= 'a' && str[i] <= 'z')check2 = 1;
		else if (str[i] >= '0' && str[i] <= '9')check3 = 1;
		else check4 = 1;
	}
	if (check1 + check2 + check3 + check4 >= 3)return true;
	return false;
}
int main()
{
	int num;
	char str[50 + 5];
	cin >> num;
	while (num--)
	{
		cin >> str;
		if (judge(str))cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}